Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework button code #9525

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open

Rework button code #9525

wants to merge 55 commits into from

Conversation

zenseii
Copy link
Collaborator

@zenseii zenseii commented Feb 3, 2025

Adjusting to this change meant addressing a lot of long standing UI visual bugs.

What this PR does:

  • Allows to generate buttons with fixed height and width. This is necessary for Add return to main menu and play map buttons to the editor #9512.

  • Allows to choose button background for fixed size generated buttons.

  • Added palette conversion table for good buttons to evil buttons. This makes it easier than trying to make evil style buttons by hand for those button types that don't have that originally, and it fixed the wrong pressed state for map select button. This will also help to add evil style buttons for the editor.

  • Improved button shine effect. Still not added for vertical buttons. It varies according to size of the button. Related to Expanding the button shine logic #9477

  • Switched to createNormalButton() in all but 1 set of buttons (vertical high scores buttons) in agg_image.cpp.

  • Renamed getTextAdaptedButton() to getTextAdaptedSprite()

  • Added black background so that we can use the smaller buttons near the well's status bar other places like in editor dialogs instead of the small buttons there.

  • Added brown background to fix see through in the kingdom overview screen. Also fixed some wrong button placement in this dialog. Part of Kingdom Overview screen, Heroes Overview and Towns/Castles Overview screens, change the frame color and adjust the position of the buttons #1843 and Kingdom Overview screen, Heroes Overview and Towns/Castles Overview screens, wrong position of elements #1842

  • Added code to generate buttons that are shorter than 96px yet taller than 25px (needed for various dialogs like view world).

  • Fix French min/max buttons transparency issues with M letter

  • Generate French and Polish MIN and MAX buttons from their original assets.

  • Remove all Italian specific button generations. The font used there is just a worse version of the one we generate.

  • Removed Medium size empty button now that we can resize in height.

  • Also a lot of button code tidying.

Other button info:

Text buttons that the engine needs to be able to make are these three:

  1. fixed dimensions, provided by getCustomNormalButton() which is called by makeButtonSprites() in ui_button.cpp and createNormalButton() in agg_image.cpp. The only difference is that makeButtonSprites() doesn't translate text. Perhaps they could be combined.
  2. Text-adaptable dimensions, provided by getTextAdaptedSprite() in ui_button.cpp.
  3. a group of buttons with equal dimensions, not provided yet but should be in ui_button.cpp.

Then there's a couple of calls to make/render buttons from various methods of fheroes2::StandardWindow. Ideally there should be a way to generate a window which adjusts its size according to the size of the buttons, to avoid any translations going outside of the window border.

@zenseii zenseii added improvement New feature, request or improvement ui UI/GUI related stuff translation Things related to languages and translations labels Feb 3, 2025
@zenseii zenseii added this to the 1.1.6 milestone Feb 3, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

src/fheroes2/agg/agg_image.cpp Outdated Show resolved Hide resolved
src/fheroes2/gui/ui_button.cpp Show resolved Hide resolved
src/fheroes2/gui/ui_button.cpp Show resolved Hide resolved
@zenseii zenseii added the bug Something doesn't work label Feb 6, 2025
@zenseii zenseii marked this pull request as ready for review February 6, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something doesn't work improvement New feature, request or improvement translation Things related to languages and translations ui UI/GUI related stuff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants